<?php
//=======================================
//###################################
// Kayako Web Solutions
//
// Source Copyright 2001-2004 Kayako Web Solutions
// Unauthorized reproduction is not allowed
// License Number: $%LICENSE%$
// $Author: vshoor $ ($Date: 2005/05/26 22:02:02 $)
// $RCSfile: staff_comments.php,v $ : $Revision: 1.2 $ 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//###################################
//=======================================


if (!defined("INSWIFT")) {
	trigger_error("Unable to process $PHP_SELF", E_USER_ERROR);
}

// First fetch the comment
global $dbCore;
$_comment = $dbCore->queryFetch("SELECT * FROM `". TABLE_PREFIX ."comments` AS comments LEFT JOIN `". TABLE_PREFIX ."commentdata` AS commentdata ON (comments.commentid = commentdata.commentid) WHERE comments.commentid = '". intval($_REQUEST["commentid"]) ."';");
if (empty($_comment["commentid"]))
{
	exit;
}

switch ($_comment["commenttype"])
{
	case COMMENT_KNOWLEDGEBASE:
		require_once ("./modules/knowledgebase/staff_comments.php");
		break;
	case COMMENT_DOWNLOADS:
		require_once ("./modules/downloads/staff_comments.php");
		break;
	CASE COMMENT_NEWS:
		require_once ("./modules/news/staff_comments.php");
		break;
	CASE COMMENT_TROUBLESHOOTER:
		require_once ("./modules/troubleshooter/staff_comments.php");
		break;
}

/**
* ###############################################
* EDIT COMMENT
* ###############################################
*/
if ($eventaction == "editcomment")
{
	if ($_POST["step"] == 1)
	{
		if (trim($_POST["fullname"]) == "" || trim($_POST["contents"]) == "")
		{
			$errormessage = $_SWIFT["language"]["requiredfieldempty"];
		} else {
			updateComment($_comment["commentid"], $_POST["fullname"], $_POST["email"], $_POST["contents"]);

			printRedirect(sprintf($_SWIFT["language"]["commentupdconfirm"], htmlspecialchars($_POST["fullname"])), getCommentURL($_comment["commenttype"]));
			exit;
		}
	}

	$_POST = array_merge($_POST, $_comment);

	$interface->staffHeader($_SWIFT["language"]["editcomment"], $_comment["commenttype"]);

	$interface->staffNavBar('<a href="index.php?_m=core&_a=editcomment&commentid='. intval($_comment["commentid"]) .'" title="'.$_SWIFT["language"]["editcomment"].'">'.$_SWIFT["language"]["editcomment"].'</a>', "", $_comment["commenttype"]);

	printInfoBox($infomessage);
	printErrorBox($errormessage);

	renderCommentForm();

	$template->assign("backurl", getCommentURL($_comment["commenttype"]));

	$interface->staffFooter();
}
?>